package com.zcn.io.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zcn.io.common.entity.OrderMain;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.api.entity.StudioExpenses;
import com.zcn.io.web.api.query.StudioExpensesQuery;
import com.zcn.io.web.service.StudioExpensesService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/10/4 21:27
 * @Copyright (c) 2024, 江苏金恒信息科技股份有限公司
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/studioExpenses")
public class StudioExpensesController {

    private final StudioExpensesService studioExpensesService;


    @GetMapping("/list")
    public CommonResult<Page<StudioExpenses>> list(Page<StudioExpenses> page, StudioExpensesQuery orderMain) {
        studioExpensesService.list(page, orderMain);
        return CommonResult.success(page);
    }

    @GetMapping("/getTotalAmount")
    public CommonResult<String> getTotalAmount(StudioExpensesQuery orderMain) {
        String totalAmount = studioExpensesService.getTotalAmount(orderMain);
        return CommonResult.success(totalAmount);
    }

    @PostMapping("/save")
    public CommonResult<String> save(@RequestBody StudioExpenses orderMain) {
        studioExpensesService.save(orderMain);
        return CommonResult.success("保存成功");
    }

    @PostMapping("/updateById")
    public CommonResult<String> updateById(@RequestBody StudioExpenses orderMain) {
        studioExpensesService.updateById(orderMain);
        return CommonResult.success("修改成功");
    }

    @DeleteMapping("/deleteById")
    public CommonResult<String> deleteById(String id) {
        studioExpensesService.deleteById(id);
        return CommonResult.success("删除成功");
    }
}
